 
//验证码验证方法
function check(){
    var y_box = document.getElementsByClassName("yanzheng_box")[0];
    var youxiang_text = document.getElementsByClassName("fa-shield")[0];
    y_box.style = "border-bottom: solid 1px #333;"
    youxiang_text.style = "color: #333; font-size:16px;"
    /*
    验证码的代码
    */ 

  }
 
 
//--------------------------------------------登录方法----------------------------------------------

//http://120.77.149.2/Merchant/Passport/CheckIn?account=Administrator&password=FD07520976B0CD45E437A9E935BEBE35
//var button_1 = document.getElementById("button_1");
//button_1.click = signIn()

 
 function signIn(){
 	var location_sign = "120.77.149.2";
	var email = document.getElementById("email").value;
	var Password = document.getElementById("password").value;

	// md5加密账号、密码
	var email_md5 = md5(email).toUpperCase();
	var password_md5 = md5(Password).toUpperCase();
	console.log(email_md5)
	console.log(password_md5)
//	var email_md5 = 'Administrator';
//	var password_md5 = 'FD07520976B0CD45E437A9E935BEBE35';

	
	$.ajax({
	url: "http://"+ location_sign +"/Merchant/Passport/CheckIn?account="+ email_md5 +"&password="+password_md5,
//	data:{account: email_md5, password: password_md5},
	type: "POST",
	dataType:'json',
	success:function(data){
		console.log(data)
			if (data.Status != 1) {
		//失败状态
		return alert(data.Message==null?"error":data.Message)
	}else{
		//成功状态
		// console.log(data.Data.Account)
		// console.log(data.Data.MerchantName)
		// console.log(data.Data.GroupName)
		// console.log(data.Data.AccessToken)
		// console.log(data.Data.APIHost)


		var Account_V = data.Data.Account;
		var MerchantName_V = data.Data.MerchantName;
		var GroupName_V = data.Data.GroupName;
		var AccessToken_V = data.Data.AccessToken;
		var APIHost = data.Data.APIHost;


		setCookie("Account",Account_V,30);
		setCookie("MerchantName",MerchantName_V,30);
		setCookie("GroupName",GroupName_V,30);
		setCookie("AccessToken",AccessToken_V,30);
		setCookie("APIHost",APIHost,30);


		// deCookie("汲英豪")
		console.log(document.cookie)
		if($("input[type='checkbox']").is(':checked') == true){
			window.location.href="index.html";
			console.log(document.cookie)
		}else{
			$(".modal-body").html("请阅读同意条款，并同意方可提交！");
		$('#myModal').modal('show');
		}
		// window.location.href="index.html";
		// console.log(data)
	}

	},
	error:function(el){
		console.log(el)
		$(".modal-body").html("密码或账号错误，请重新登录！");
		$('#myModal').modal('show');
	}
	});

	console.log($("input[type='checkbox']").is(':checked'))

}


//***********************************************
//名字：setCookie（） 
//功能：保存一个cookie的方法
//说明：cname 名字   cvalue 值  exdays 时间（天）
//***********************************************
	function setCookie(cname,cvalue,exdays){
  var d = new Date();
  d.setTime(d.getTime()+(exdays*24*60*60*1000));
  var expires = "expires="+d.toGMTString();
  document.cookie = cname + "=" + cvalue + "; " + expires;
}
//setCookie('汲英豪',"jiyinghao",2)



//***********************************************
//名字：getCookie（） 
//功能：取出一个cookie的方法
//说明：cname 名字
//***********************************************
function getCookie(cname){
  var name = cname + "=";
  var ca = document.cookie.split(';');
  for(var i=0; i<ca.length; i++) 
  {
    var c = ca[i].trim();
    if (c.indexOf(name)==0) return c.substring(name.length,c.length);
  }
  return cname;
}


//var md5 = md5(123).toUpperCase()
//console.log(md5)


//***********************************************
//名字：deCookie（） 
//功能：删除一个cookie的方法
//说明：cname 名字）
//***********************************************
	function deCookie(name)  
{  
    var exp = new Date();  
    exp.setTime(exp.getTime() - 1000);  
    var cval=getCookie(name);  
    if(cval!=null)  
    document.cookie= name + "="+cval+";expires="+exp.toGMTString();  
} 